using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.SqlClient;

public partial class signup_ActivateAccount : System.Web.UI.Page
{
    private Database m_db;

    protected void Page_Load(object sender, EventArgs e)
    {
        String email = null;
        int userid = -1;

        m_db = DatabaseFactory.CreateDatabase(ConfigurationManager.AppSettings["ConnectionStringName"]);
        Page.Title = "Aktivering af din konto";

        try
        {
            email = Request.QueryString.Get("e");
            userid = Convert.ToInt32(Request.QueryString.Get("u"));

            if (email == null)
            {
                FAILURE.Visible = true;
                return;
            }

            if (userid <= 0)
            {
                FAILURE.Visible = true;
                return;
            }

            DbCommand cmd = m_db.GetStoredProcCommand("UserAccountActivate");
            cmd.Parameters.Add(new SqlParameter("@email", email));
            cmd.Parameters.Add(new SqlParameter("@userid", userid));
            userid = Convert.ToInt32(m_db.ExecuteScalar(cmd));
            if (userid > 0)
            {
                OK.Visible = true;
            }
            else
            {
                FAILURE.Visible = true;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
}
